define([
        'app/utils/WebUtils',
        'app/service/GeneralServices',
        'underscore',
        'app/utils/UploadLogoUtils',
        'app/utils/AMUICookieUtils',
        'app/utils/CommonUtils'
        
        
        ], function (
        WebUtils,
        gs,
        _,
        UploadLogoUtils,
        AMUICookieUtils
    ) {
	
	var opt ={};
	var p1 = {};
	
	opt = p1 = AMUICookieUtils.initializePage(true);
	
	opt.navi_main = "新建用户";
	opt.navi_sub = "添加新的用户";
	opt.copyrighttext="";
	WebUtils.adminPageInt(opt);
		
	
	$("#wjt_user_info_save").click(function(){
		
		var name = $("#wjt_user_name").val();
		var phone = $("#wjt_user_phone").val();
		var email = $("#wjt_user_email").val();
		var pwd = $("#wjt_user_pwd_new").val();
		
		if($.isNullStr(name)){
			WebUtils.alert("名字不能为空");
			return;
		}
		
		if(!$.isEmail(email)){
			WebUtils.alert("请正确输入邮件地址");
			return;
		}
//		if(!$.isTel(phone)){
//			WebUtils.alert("请正确输入手机号");
//			return;
//		}
		if($.isNullStr(pwd)){
			WebUtils.alert("密码不能为空");
			return;
		}

		var thumb = $("#wjt_user_thumb").attr("src");
			
		var p = {
			name:name,
			email:email,
			phone:phone,
			pwd:pwd,
			thumb:thumb
		};
		gs.userinfo_create(p,function(resp){
			if(resp.status != "200"){
				WebUtils.alert("操作未成功，请重试");
				return;
			}
			$.redirectTo("admin-member.html");
		});
	});
	
	var url = "/wjt/upload_user_thumb_create";
	UploadLogoUtils.initSingleImage("wjt_user_thumb_upload_container","wjt_user_thumb_upload_btn",url,
		function(up, file, info){
			var resp = JSON.parse(info.response);

			$("#wjt_user_thumb").attr("src","/attachment/img/"+resp.result.key);
			//"{"status":"200","result":{"path":"http://localhost:8014/attachment/img/ac3f7f1d-4462-4362-8363-8a08826ebe82","key":"ac3f7f1d-4462-4362-8363-8a08826ebe82"}}"
		});

	
	return;
});